the body of this if is repeated below with different args, maybe a function