Fixing crashing bug