main code from tutorial