restructiring the code