separated sequence caluclator into separate function