Refactor up function