replaced assert which numba doesn't support with if/else