Removed a small bug in calling _updateHIstory() and commented out unnecessary statements.
Also introduced a few break statements to prevent redundant iterations.