adding defensive checks