found older attempt at this, with some work done