fixed to accept 3d inputs