Optimze code structure