undefined vars error fixed