cleaned up the getTargetShape function