restructing code