Adapted to JDK 1.7