refined algorithm solutions to some problems