Trimmed unneeded code and refracted.