cleaned code to make upgrades easier