Moved all the logic to these files