moving some pretti code to subroutine