Refactored fetch_by and fetch_where