updated structure, function names and comments