separated logic from draw interval function