Eliminated need of else statement and check for class_exists in the right place