added checking for input array so we can catch empty input array