Optimized decode method to be faster (implemented with hashtable)