fixed fanOut, minor refactoring