Reorganize existing code