Updated code for MODE setting