Fixed ugly code