oops, reverting 1404f5f03498aa1a893b81b8d4495d7eedf5f1b7
use for/in/when, althogh I'm not quite happy with this yet