added condition when fetching database entities