An algorithm for calculating the cycletime and greentimes for a signalized intersection