shorter code, also working. pretty good improvement!