refactored parser: much better readable