replaced getExtension() to be compatible with PHP < 5.3.6