Refactor this to actually work