Refactory to reuse code

See #3
Refactory in ns and ds rules for better maintenance
Still needs to work on it

See #4