limit keys from the database query
NPE fix