move map logic to separate file