added nan support