prepared
added working solution (still ugly, should this be angular code?)