fixed broken function and changed variables