Remove bug, better handling of error