trying to fix logic bug