Solved the hanging problem while inserting