refactor map select function