Fix some errors in logic
Fix logic