second attempt at refactoring resources controller code.