added some error messages and stuff