first try converted from http://lpmuds.net/smf/index.php?topic=488.0