Modified script for fetching books according to classes