fix #1 + changes suggested by @frol