Things should be working now
Cleaned up the code a bit