edited code as called for in the assignment