added mode1 function