changed function to separate function