adding code for pre-java-8 as well