Improved code in model