Fixing history.back() bug