improve error checking
make use of map()
internal redesign