fixed some logic, W3 compliance