some refactoring
MERGED