modifed hash function to check for small len