working version of sztanpet rewrite