Error handling and margin issue