My implementation for assignment 2.