Rewrited for Java 8