refactoing, added proccessExternalCallback function