Fixed possible crashing