move map var inside function. Modify commands to direction and map direction.