Updated code with modules