fixed regression from prev commit
rearranging code to be modularized
modularized map