format and compile code, added comments