moved data checks outside function and passed axes as first parameter