try to code in functional style