Improve code to avoid multiple get()