few fixes for combining duplicate codes