minor changes for getting the value of q