input map function, some refactoring