fix logic, thanks to Jaume