Refactoring of ls command

Code review please. I'm not sure this is better. It may even be worse :/