improve code using user variable from method parameter