Added error checking/handling