moved some functions to shared and moved logic to background.