some refactoring in helper_functions.rules