fixed bug that would cause a crash sometimes.