Added basic exception handling