moved checks to main function to avoid ufunc call