merge with kostya version