Removed spurious space
Updated error handling