fixed error in writing out profile