Refactor modal into a factory. Implement gotem setting