restructed app code