changed code structure