First try of solving prog assignment 2