changed old function to this