Close, still needs debugging.