changed variables and procedure