Adding extra code to accommodate to Java 7