Fixes a bug in history order