Implementation along with tests