changed code because code minimization caused problems