improve system detect function