Fix crashing bug