added comments and reqorked