refact according to spec