Refactored composite function completely
Fixed problem with reset in position iterator