Now uses defined functions