change function and cleanup