Fixed undefined results in better way.