Refactored users controller for easy reuse