fixed the crashing bug