First implementation largely works