added error hadling