Smarter implemention...

...and less code