Refactored function to return instead of echo

Used function for tests on variables based on their return of T/F in
function