refactored linkRequest code with error codes