better expansion rule
some refactoring