Added more checking to parser