add formatting

add formatting & some refactoring