Add 'before' hook to remove duplicated code