trying to fix memory corruption issue