writing fg and bg functions, working