updated scope and fixed some bugs
updated example