added deletion of old file and sqldb clean up