used helper functions to make code simple.