fix some indentation and code organization