Fixed the code for java 6