refactor books factory