refactor man code