maim function updated