Refactor link type determination