Moved logic to an angular controller, and fixed logic.