Implemented dynamic lookup table. Much faster runtime (less repeitive calculations).