updated to reflect modifications to the code