Cleaning up the code. The hybrid (map + scan) version is a bit faster than the one that is based on the scan.