refactor and create functions for next frames