changed code organization