DRY up the code