Added some general logic

More to be added later