boolean logic error with ensuring paste
updated version