code largely cleaned up