replaced older version of code