change var name and fix logic if