fixing crashing bug