last working version with my own modification