Assignment 5.1 version 02 shorten code