REFACTOR to use Angular JS better