Reformated list printing and replaced if/else with ternary operator