faster version without arrays dump in each step