update DB create and update method. Rewrite several if/else statement into single line expression