added ar's repo and tidied up code a little