Fixed database query issue. Trying to figure out how to condition the returned data