updated to work with contemporary version of PHP ;)