fixed the GS algorithm