Modified alghoritm for tests