fix for http://phphub.org/topics/4