added balance testing code