working version
everything merged