Refactored this now as you suggested.