porting code from division-project