Added checks that attributes exists before accessing them