refactored, added support for user-defined parameterized types