Removed duplication in controllers by extracting a module