fix bug for checking `sys` before using