refactor and add map