refactor sprites and move some functions to sprites file