Refactor to use emberjs