changed the parsing function and put other functions in order