fixed copy app related issue and clean up the code