use result code properly