refactored parse method