submission in correct format, fixed some parsing bugs, refactoring code