refactor timeline calculation to own function