Copy & paste of previous function with a minor change. Please merge the code. Do the checks in one loop.