Fully working on PHP5.4 and above