finished assignment 4 code