refactored code to work with Java 1.6 - just in case users have older version of java