change to more functional approach