First attempt at sub terms

Not sure how this is performance wise but it's a start