making the function more flexible