Refactor selectParser function