made reusable function