+optimizing, first roughly functioning version