factors out map