Assignment #4 works (could use some improvement)