Now works with PHP v5.3 and code looks more pretty