You could consider putting this in a function on the scope instead.