Error handling changed
Implemented image preview