first draft ready.  everything is formatted but the code is still not very clean