Some code rewrited