started work on second function but have deeper issues to resolve