early and naive (but working) implementation