Refactor notebook