edited parsing function