Mostly working version