make function more reusable