beautifying and refactoring

Change-Id: I8d0e71bb617842553aa61f063b321e6c4e5e9684