fix freezing bug