changed exception handling to be pre Java 1.7 compatible