implement min and max for repeat