refactor and document comp function
styling: get everything to fit in 80 lines