fix readability and flow errors