re factored code to make it simple