Add check for nil error pointer