code structure improved