refractor and adding another functions