optimize and fix, add new function to Common.func.php