tried to make it DRY a little