Added logic for updating posts