fixed the hanging problem