Cleanup duplicated code