Updated Code to check classes instead of booleans, eliminated some unnecessary code