Added error handling to parser