added quite a number of changes