modified with if/else and new variables