Made work function fetch origin, and made SMDB function