The return value of the function was wrong. Error corrected