regorganized code structure