hw3, task 3 + fixes for task 2.