Added null check to attributes