encapsulated  and adusted some indent