Look at the Application Notes about In-Application Programming (IAP) - including AN2557...
A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work.