more docs and break up code