implemented ifthenelse