Refactiorization, remove unnecessary code