Fixed freezing bug