code refactoring for Ganelon tutorial