starting refactor to register mode