added check for nil response