- code cleaned up and documented a bit