Fixed code behavior to comply with assignment spec