added original code from tutorial