Removed duplicate variable check, improved formatting