Move method so it's only called when necessary

Small performance improvement for getAttribute