Optimized searchBooks() to reduce number of SQL queries