Added logic in books controller