more functions

added macro to handle errors