added small error check