updated code (see changelog in readme)