Fixed out of bounds error with function picking