I think this would be more clear as an if(){} ... else{} construct without a $ds_exists variable as it was before.  Also, isset() may be a more semantic choice than empty().