Implemented solution to assignment