added check for required fields, cosmetics