more robust to bad inputs