Rewritten the grab function and added a new function called 'toggle'