refactored the parse method