rewrite code, add addBook() function