When I put NEXT just before END FUNCTION I don't get any error... but another issue is that you want to address is that you want to use "DELETE SMbit" because you're deleting that specific item of the type, not the type itself.
Hopefully that helps a bit.
Hopefully that helps a bit.