replace on prefix instead of msg and cleanup