fixed bug that was causing random crashes