Added lookup based approach, which is by far the fastest.