added in error checking