made code a little more robust