Revert "Revert "Update speed function""

This reverts commit f9f1af7f96a9903f16d0839347064be8ad88ba00.