encapsulate into a function for easy use