code edited for final