reformatted & condensed code