still trying to find strange memory corruption bug