more robust and correct