Separated bean add and put in catch

Split up adding the bean from the writing method  and added in catch
blocks where necessary