Refactor 2

- extract functions
 - format of output
 - test for resolution
- extract array into var for better intent