added error checking

Signed-off-by: vito <bovitobo@yahoo.com>