Rebuilt to be simpler and actually work