added the AA loop and read loop