refactor and add license