DRY up some functions