Speeded it up by a factor ~20 using lookup list