fixed a bug causing crash