fixed utility methods to handle errors properly