tweaked the code