more valid and beautified code