Refactor and stylstic changes