Implemented Error Checking