clean code and do some refact