added some euristics to reduce the number of nodes