Imrove Function and add spec