fix interval function