Removed duplicate if statement
Fixed code formatting