Added comments explaining function purposes