minor attachments js refactoring