trying to reduce duplicate code.