make code a little more robust