Moved parsing logic to parser.py