Removes unused code and use sprintf to be more readable