put attachrid in if statement