code cleaning + some refactor