optimized the database query :)