modified the methods to take a parameter for speed