changing to a functional approach