implemented Tero's comments