tad bit better error check