added database constraints and made my first begin - rescue - end