Refactor codes

the epicest refactor ever