fixed scope implementation
updated version