final with minor changes