refactor interval transform into separate function