minor changes + error handling