This duplicated codes should be removed. Updated with another method to avoid this.