some minor changes to make the code nicer :)