DRY up two functions