looks like this function can move to the external file as well