Added the use function and fixed some bugs