added simple exception handling