kinda working now (though it is still pseudo-optimal)