added implementation of assignment 3