Fix NULL check and consider the case when no args are specified