private void delete(String bookId) {

    User user = ProfileController.getAuthenticatedUser();
    user.getBooks().remove(bookId);

    userService.save(user);
    ProfileController.authenticateUser(user);
  }
  // lazy removing
  private void updateUsersBooks(List<Book> books) {

    List<String> changedList = new ArrayList<String>();
    for (Book b : books) changedList.add(b.getId());

    User user = ProfileController.getAuthenticatedUser();
    user.setBooks(changedList);
    userService.save(user);
    ProfileController.authenticateUser(user);
  }
  @RequestMapping(value = "/library/add", method = RequestMethod.GET)
  public String addBookToLibrary(@RequestParam(required = true) String id) {

    User user = (User) ProfileController.getAuthenticatedUser();
    if (user.getBooks() == null || !user.getBooks().contains(id)) user.addBook(id);

    userService.save(user);
    ProfileController.authenticateUser(user);

    return "redirect:/library";
  }