Abstracting code to helper functions