add return code to avoid close window in func