Should probably add some tests for this