updated for use with java 7, breaks java 6 atm