fixed some errors with duplicate variables