Upgrading code to 3.x