added loading template to onBefore hook