updated for 1.7 (untested)