Improve the scan func readability by writting some comparison funcs.