added comments

added comments and cleaned code a little