Refactor links gen