added ranges and some syntax cleverness