Added check for attributes not nil