Added better error handling (stack trace