semi-working version; last one before I scratch and go with danieltoshea