Remove redundant if check and remove rare error