fix bug on visiting the different h values, maybe a specific structure should be used