refactor status and code