first working draft...

need more clean up and optimizations