fix a bug where mouse doesn't get trapped properly