fix logic, it was totally flawed