algorithm changed for mode A2