refactors the code completely.