cleaning up function flow