polishing and error handling