reconsitution code to be more flexibility