pretty much works and is robust. shell script included