now returns bucket instance and added some exeption checking