now creating save current state func