added defensive coding to check getAttributes exists before calling it