changed speed to @speed and fixed duration formula