Removed tabs and trailing spaces and created a function to calulate parity