Replace occurrence of a list with another?



Hello all,

Need to replace all occurrences of an element in another list with
another? X being the element i wish to replace and Y being the element
to replace it with so when i issue:

?- replaceall(a,b,[a,b,c,d],L).

It should return L = [b, b, c, d] but i get two values back for L;

L = [b, b, c, d] ;
L = [a, b, c, d] ;

It seems to be returning both the new list and the old list.. why is
this? The predicate is below:

replaceall(X,Y,[H|T],[Y|List]) :-
X = H,
replaceall(X,Y,T,List).

replaceall(X,Y,[H|T],[H|List]) :-
replaceall(X,Y,T,List).

replaceall(_,_,[],[]).

Many thanks in advance!

PS - using SWI-Prolog by the way.
PPS - and how would i change this to just replace the first occurence?

.