now throws exception for q <= 0