documentated the code a bit