adding some documentation, cleaning up the code a little