Rewrited some code