slight change based on last version, make the code structure more clear