adding latest changes
better error handling