changed the code structure;