sub logic