refactor loan calculator