implemented fix based on Phanx' add-on.