Moved constructor code to a constructor