modified code to fit jdk 1.6