added more variables and made some corrections