Refactoring

* Made getCon function more useful
* Moved getCon function to separate file