code structure fixes