added dynamic number of bins