Error checking implemented