refactored the controller so that it can access the whole app. created a function to get one entity