almost working
cleaning up code