Changed catch block to be compatible with JRE6