Refactor each function to return the result, removing the echo