fixed set_style method, refactored code for setting format