Added qFuncation calculation