fix bug in result for repeated numbers
add rules