Added the edit link and refactored some codes