check some function return value, beautify code