adapting for functional programming