Improved assignment code