Refactor code in tip calculator version 3