Added logic for SOP and loaded docs into database