update to simplier, clearer, implementation