Adding error check