fixed the bug with not hiding menu in some cases