added code from anmail gallery