moved code that might fail out of the constructor