Cleaning up funciont