Added update insert db methods + code cleanup & abstraction