fix random input crash