Updated some code from older version