fixed code more presentable, let's do it functional