All the `isinstance` checking in the code is not good practice. There can be common functions for type checking (if absolutely needed)