assignment 2 (cleaned up)