working solution using java 8