Start writing the wrapper function of IRWLS