update hw4

fixed some problems with the functions. Still not complete.