Added extra parameter checks for the sake of accuracy.