formatting and fix nullpointer