Disclaimer - This post along with code supporting is inspired by Chris Eidhof's talk at trySwift. I took the liberty to slightly update the code as per my own logic. There is no difference from the original source as long as user facing functionality is concerned.
This code is open