Cleaned up the code a tad