implementing loan logic