Majorly rewritten the original hashing algorithm to avoid dependency on hardcoded numbers