Moved checking functionality to a library
Moved more logic in to the library