Adding check for null variables