code re-factored.