Cleaned up the code a bit per Jwage proofread