Format document and removed unnecessary if/else statements