split token_shape feature function into several smaller functions