Fix reversing issue in parsing function