added app copy function, re-formatted code