improved a few var names, new function
adjust for better spacing