avoiding unnecessary iteration, logging errors and bytes