Protect function

Fix #3