Fixed a minor bug in attr function