Minor problem with the logic