Fixed the bug for NULL handling