fixed always logging in error