Cleaned up a bit, marginally more effecient