added model redefinition support to javascript implementation