debugging slowdown in the code