working on q functions