Refactor index and angular controller