Finished implementation of the assignment