refactored variables, made small changes