refactoring + made output pretty