separate map components and functions

code is quite incomprehensible...., everything in one file not the best
solution