modified program to get better results