refactor map into factory and wrap up launching code into anon function