merged to master -- good working version