Added better formatting and commenting