fixed the hanging bug