add robustness to different shape inputs