I made this a little more robust