now works for 4 links