Revised code structure