cleaned up working code