Created subroutine to account for variables, buggy atm