fixing freezing bug