setBits function works properly with x,y,n,p inputs