working spec. Needs some refinings