refactored and documented network