Fixed code to work with PHP 5.4. empty was bad.