DRY stuff up using an auxilliary function