Move logics outside of RESPOND block