written in functional method