fix bug where it always logged an error