tweaked the code to make it shorter