added links and cleaned up code