partial commit - this code is trash and v unsafe, but might work as a base