Adapted for QAOSP