some rundementary error handling to try to make this more robust