Extract interval function to independent class