ERROR CHECKING ADDED