Use a function to do right check