adding some error control