added ID into links
refactoring a bit of code