added replace errors to .encode in command()