Refactored Books Controller and added edge cases