move logic to small functions
finish up