reformatted function