tested and working ex 1 on hw3