refactor controls code into module (class)