error handelling added