Fixed: Bug in is_valid method