Improved code flow