Added many checks for null values