Refactored error handling. Use panic instead of just ignoring error.