refactor getsubtypes and add javadoc