add basic logic and test

should do the trick.