Refactor nBack Angular Code