created frameByFrame function