custom exception handeling improved