some refactoring
updated