Structurize code in more conventional way