Removed debug code and added an error alert