fixed database query bugs in recommendations