add further error checking