refactored to jdk6 compatibility