Arguments are not sufficiently instantiated swi-Prolog
===

I trying to write a Prolog script that can create a list of strings that would after a simple procedure result in a given string. My knowledge of Prolog is very limited and I am not sure it is even able to perform this, so please tell me if it's impossible.

I got this so far

    replace_word(Old, New, Orig, Replaced) :-
    atomic_list_concat(Split, Old, Orig),
    atomic_list_concat(Split, New, Replaced).

It can perform this operation

    10 ?- replace_word('a','e','glava',X).
    X = gleve.


But it cannot backtrack it

    11 ?- replace_word('a','e',X,'gleve').
    ERROR: atomic_list_concat/3: Arguments are not sufficiently instantiated
    
I can imagine what causes the problem, but is there a way around it?