Sorted functionality into functions.