restored parts of rulex' version