refactor($parse): refactor repeated code