made it a bit more robust