Refactored books controller