moved errors into a helper