some scope cleanup. use more angular instead of self programmed js