Defensive programming: check functions arguments