logical errors fixed