this is the way + other code improvements