adding error logging