A few helper functions implemented necessary to implement the idea.