Rewritten to use anguar js