Basic algorithm implemented, now we need to handle exceptions
Cleaned up the code a bit