Modularize hash function