Refactored and pass variables as argurments