refactor market