bug and crash fix