remove redundant code and use java 6