refactoring and handling nre