Refactored out function to find a specific entity