refactoring and widening of functions started