Changed variable names and simplified code