Error check was missing in some places