Added error/exit handling