improved angle function. Changes speed variable