cleaned up a function