Refactor verbose code and improve indenting