making progress, although still pretty rough.
i'm sure there is a more efficient way of doing this