bug fix with validation