fastest implementation so far at 0.9sec