refactoring to __contains__ method of network