updated porting from original tutorial
added new structure