fixing speed is not defined issue