improved to functional programming