added better mysql query.