refactor and cleanup controllers