Added aiquality

Added aiquality and the quality function