This seems to be duplicated -- maybe we can consolidate the code under another class