tutorial refactored - some fixes