Fix bug: attributes variable declared in wrong place.